#include<string>
#include<iostream>
using namespace std;

//class Solution
//{
//public:
//    string addStrings(string num1, string num2)
//    {
//        auto end1 = (num1.size() - 1);
//        auto end2 = (num2.size() - 1);
//        int key = 0;
//        string str;
//        int a = 0, b = 0;
//        while (end1 >= 0 || end2 >= 0)
//        {
//            a = end1 >= 0 ? (num1[end1]) - '0' : 0;
//            b = end2 >= 0 ? (num2[end2]) - '0' : 0;
//            int ret = a + b + key;
//            key = ret / 10;
//            ret = ret % 10;
//            str += (ret + '0');
//            end1--;
//            end2--;
//        }
//        reverse(str.begin(), str.end());
//        return str;
//    }
//};

class Solution
{
public:
    int firstUniqChar(string s)
    {
        string str = s;
        int right = str.size() - 1;
        int left = 0;
        while (1)
        {
            if (left > str.size() - 1)
                return -1;
            if (right == 0)
                break;
            if (left >= right && str[left] != str[right])
            {
                break;
            }
            else if (left >= right && str[left] == str[right])
                return -1;
            if (str[left] != str[right])
            {
                right--;
            }
            else
            {
                left++;
                right = str.size() - 1;
            }

        }

        return left;
    }
};

int main()
{
    
    Solution s;
    string a("loveleetcode");
    s.firstUniqChar(a);
    /*string s3=a.addStrings(s1, s2);*/
    cout << a << endl;
    return 0;
}